/**
 * @file 04-class-extend.ts
 * 
 * 1.3.4 使用对象展开赋值属性
 */

import { Grid, Margin } from "./02-intersection-types"

function ConsolidatedGridClassExtend(grid: Grid, margin: Margin): Grid & Margin {
    // let consolidatedGrid = <Grid & Margin>{...grid,...margin};
    let consolidatedGrid = <Grid & Margin>{ ...margin, ...grid };
    // consolidatedGrid.Padding = margin.Padding ? margin.Padding : grid.Padding;

    return consolidatedGrid;
}

let grid: Grid = <Grid>{ Height: 20, Width: 10, Padding: 20 };
let margin: Margin = <Margin>{ Left: 5, Top: 5, Height: 5, Width: 5, Padding: 10 };
let x = ConsolidatedGridClassExtend(grid, margin);

console.log(`Left : ${x.Left}, Top : ${x.Top}, Width : ${x.Width}, Height : ${x.Height}, Padding : ${x.Padding}`)
